package com.kc.gb.device.service.impl;

import com.kc.gb.device.common.properties.DeviceConfiguration;
import com.kc.gb.device.common.properties.DeviceProperties;
import com.kc.gb.device.common.properties.YamlHelper;
import com.kc.gb.device.service.ConfigAdminService;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;

@Service
public class ConfigAdminServiceImpl implements ConfigAdminService {

    @Override
    public void flush(DeviceProperties deviceProperties) throws Exception {
        String configPath = DeviceConfiguration.getConfigPath();
        File file = new File(configPath);
        YamlHelper.writeObjectToYaml(DeviceProperties.class,deviceProperties,file);
    }
}
